package com.macro.mall.portal.controller;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.model.UmsMember;
import com.macro.mall.portal.dto.BmsFeedBackDetail;
import com.macro.mall.portal.dto.BmsFeedbackParam;
import com.macro.mall.portal.service.BmsFeedBackService;
import com.macro.mall.portal.util.UserUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 轮播图管理Controller
 * Created by macro on 2018/4/26.
 */
@Controller
@Api(tags = "BmsFeedBackController")
@Tag(name = "BmsFeedBackController", description = "留言建议")
@RequestMapping("/feedBack")
public class BmsFeedBackController {
    @Autowired
    private BmsFeedBackService bmsFeedBackService;

    @ApiOperation("添加留言建议")
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<?> create(HttpServletRequest request, @RequestBody BmsFeedbackParam bmsFeedbackParam) {
        int count = bmsFeedBackService.create(request,bmsFeedbackParam);
        if (count > 0) {
            return CommonResult.success(count);
        } else {
            return CommonResult.failed();
        }
    }

    @ApiOperation("根据id获取留言建议信息")
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<BmsFeedBackDetail> getItem(@PathVariable Long id) {
        BmsFeedBackDetail bmsFeedBackDetail = bmsFeedBackService.getItem(id);
        return CommonResult.success(bmsFeedBackDetail);
    }

}
